﻿@page "/users/add"
@using Microsoft.AspNetCore.Authorization

@attribute [Authorize]

<h1>Benutzer anlegen</h1>

<hr />

<EditForm Model="@user" OnValidSubmit="Save">
    <DataAnnotationsValidator />

    <div class="mb-3">
        <label for="Email" class="form-label">E-Mail</label>
        <div class="col-md-4">
            <InputText id="Email" class="form-control" @bind-Value="@user.Email" />
        </div>
        <ValidationMessage For="@(() => user.Email)" />
    </div>
    <div class="mb-3">
        <label for="Firstname" class="form-label">Vorname</label>
        <div class="col-md-4">
            <InputText id="Firstname" class="form-control" @bind-Value="@user.Firstname" />
        </div>
        <ValidationMessage For="@(() => user.Firstname)" />
    </div>
    <div class="mb-3">
        <label for="Lastname" class="form-label">Nachname</label>
        <div class="col-md-4">
            <InputText id="Lastname" class="form-control" @bind-Value="@user.Lastname" />
        </div>
        <ValidationMessage For="@(() => user.Lastname)" />
    </div>

    <div class="mb-3">
        <label for="password" class="form-label">Passwort</label>
        <div class="col-md-4">
            <InputText id="password" type="password" class="form-control" @bind-Value="@user.Password" />
        </div>
        <ValidationMessage For="@(() => user.Password)" />
    </div>
    <div class="mb-3">
        <label for="passwordConfirm" class="form-label">Passwort bestätigen</label>
        <div class="col-md-4">
            <InputText id="passwordConfirm" type="password" class="form-control" @bind-Value="@user.PasswordConfirm" />
        </div>
        <ValidationMessage For="@(() => user.PasswordConfirm)" />
    </div>

    <div class="form-group">
        <button type="submit" class="btn btn-primary" @onclick="Save">Speichern</button>
        <button class="btn btn-light" @onclick="ReturnToList">Abbrechen</button>
    </div>
</EditForm>